<?php

namespace App\Http\Service;

use App\Libs\HttpCurlLibrary;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;
use App\Services\Ip2RegionService;

#获取ip地址区域名称
class IpService extends BaseService
{
    private $ip2RegionService;
    public function __construct(Ip2RegionService $ip2RegionService)
    {
        parent::__construct();
        $this->ip2RegionService = $ip2RegionService;
    }

    

     /**
     * 获取客户端IP信息
     */
    public function clientInfo($request)
    {

        $result = $this->ip2RegionService->getClientInfo();
        return $result;
     
    }
        
    public  function getIp($request,$ip='')
    {
        if(empty($ip)){
            $ip=$this->clientInfo($request);
        }
        $result = $this->ip2RegionService->search($ip);
        return $result;
    }

}
